package com.example.springcloud.service;

import com.example.springcloud.pojo.User;
import feign.hystrix.FallbackFactory;
import org.springframework.context.annotation.ComponentScan;
import org.springframework.stereotype.Component;

import java.util.List;
//降级
@Component
public class UserClientServiceFallbackFactory implements FallbackFactory {

    @Override
    public UserClientService create(Throwable throwable) {
        return new UserClientService() {
            @Override
            public User queryById(Long id) {
                return new User().setId(id).setUname("id=>"+id+"没有对应的信息，客户端提供了降级的信息，这个服务现在已经被关闭")
                        .setDb_source("没有数据");
            }

            @Override
            public List<User> queryAll() {
                return null;
            }

            @Override
            public Boolean addUser(User user) {
                return null;
            }
        };
    }
}
